// 购物车信息模块(局部模块)
export default {
  namespaced: true, // 开启命名空间
  state () {
    return {
      shopInfo:[],
      siderbarList:[],
      total:0,
      amount:0,
      choosedList:[],
    }
  },
  mutations: {
    // 定义mutations，用于同步修改状态
    saveshopInfo(state, payload){
      state.shopInfo=payload
    },
    savesiderbarList(state, payload){
      state.siderbarList=payload
    },
    savetotal(state, payload){
      state.total=payload
    },
    saveamount(state, payload){
      state.amount=payload
    },
    savechoosedList(state, payload){
      state.choosedList=payload
    },
  },
  actions: {
    // 定义actions，用于异步修改状态
    // 2秒后更新状态
    // updateNickname (context, payload) {
    //   setTimeout(() => {
    //     context.commit('updateNickname', payload)
    //   }, 2000)
    // }
  },
  getters: {
    // 定义一个getters
    getshopInfo(state){
      return state.shopInfo
    },
    getsiderbarList(state){
      return state.siderbarList
    },
    gettotal(state){
      return state.total
    },
    getamount(state){
      return state.amount
    },
    getchoosedList(state){
      return state.choosedList
    },
  }
}